package set;

import java.util.HashSet;
import java.util.Set;

public class Set2 {
	public static void main(String[] args) {
		Set set=new HashSet();
		set.add(new Fruit("apple",12));
		set.add(new Fruit("apple",13));
		set.add(new Fruit("apple",14));
		set.add(new Fruit("apple",12));
		p(set);
		p(set.size());
	}
    public static void p(Object o){
    	System.out.println(o);
    }
}
class Fruit{
	String name;
	int    sweet;
	
	public Fruit(String name, int sweet) {
		super();
		this.name = name;
		this.sweet =sweet ;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		System.out.println(this.name+"-------------");
		return 12;
	}
	@Override
	public boolean equals(Object obj) {
		System.out.println(this.name+"---------"+obj);
		Fruit fruit=null;
		if(obj instanceof Fruit)
			fruit=(Fruit)obj;
		if(this.name.equals(fruit.name)){
//			System.out.println("apper again");
			return this.sweet==fruit.sweet;
		}
		return false;
	}
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return this.name+"\t"+this.sweet;
	}
}